home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / apps / 21 / emacsrc / ed.h < prev    next >
Encoding:
C/C++ Source or Header  |  1986-05-14  |  10.9 KB  |  204 lines

  1. /*
  2.  * This file is the general header file for all parts of the MicroEMACS
  3.  * display editor. It contains definitions used by everyone, and it contains
  4.  * the stuff you have to edit to create a version of the editor for a specific
  5.  * operating system and terminal.
  6.  */
  7.  
  8. #define ST520   1                       /* ST520, TOS                   */
  9. #define AMIGA   0                       /* AmigaDOS, Lattice            */
  10. #define MWC86   0
  11. #define V7      0                       /* V7 UN*X or Coherent          */
  12. #define VMS     0                       /* VAX/VMS                      */
  13. #define CPM     0                       /* CP/M-86                      */
  14.  
  15. #ifndef MSDOS                           /* Already defined for Lattice  */
  16. #define MSDOS   0                       /* MS-DOS                       */
  17. #endif
  18.  
  19. #define ANSI    0
  20. #define VT52    1                       /* VT52 terminal (Zenith).      */
  21. #define VT100   0                       /* Handle VT100 style keypad.   */
  22. #define LK201   0                       /* Handle LK201 style keypad.   */
  23. #define RAINBOW 0                       /* Use Rainbow fast video.      */
  24. #define TERMCAP 0                       /* Use TERMCAP                  */
  25.  
  26. #define CVMVAS  1                       /* C-V, M-V arg. in screens.    */
  27.  
  28. #define NFILEN  80                      /* # of bytes, file name        */
  29. #define NBUFN   16                      /* # of bytes, buffer name      */
  30. #define NLINE   256                     /* # of bytes, line             */
  31. #define NKBDM   256                     /* # of strokes, keyboard macro */
  32. #define NPAT    80                      /* # of bytes, pattern          */
  33. #define HUGE    1000                    /* Huge number                  */
  34.  
  35. #define AGRAVE  0x60                    /* M- prefix,   Grave (LK201)   */
  36. #define METACH  0x1B                    /* M- prefix,   Control-[, ESC  */
  37. #define CTMECH  0x1C                    /* C-M- prefix, Control-\       */
  38. #define EXITCH  0x1D                    /* Exit level,  Control-]       */
  39. #define CTRLCH  0x1E                    /* C- prefix,   Control-^       */
  40. #define HELPCH  0x1F                    /* Help key,    Control-_       */
  41.  
  42. #define FALSE   0                       /* False, no, bad, etc.         */
  43. #define TRUE    1                       /* True, yes, good, etc.        */
  44. #define ABORT   2                       /* Death, ^G, abort, etc.       */
  45. #define    NULL    0
  46.  
  47. #define FIOSUC  0                       /* File I/O, success.           */
  48. #define FIOFNF  1                       /* File I/O, file not found.    */
  49. #define FIOEOF  2                       /* File I/O, end of file.       */
  50. #define FIOERR  3                       /* File I/O, error.             */
  51.  
  52. #define CFCPCN  0x0001                  /* Last command was C-P, C-N    */
  53. #define CFKILL  0x0002                  /* Last command was a kill      */
  54.  
  55. /*
  56.  * There is a window structure allocated for every active display window. The
  57.  * windows are kept in a big list, in top to bottom screen order, with the
  58.  * listhead at "wheadp". Each window contains its own values of dot and mark.
  59.  * The flag field contains some bits that are set by commands to guide
  60.  * redisplay; although this is a bit of a compromise in terms of decoupling,
  61.  * the full blown redisplay is just too expensive to run for every input
  62.  * character. 
  63.  */
  64. typedef struct  WINDOW {
  65.         struct  WINDOW *w_wndp;         /* Next window                  */
  66.         struct  BUFFER *w_bufp;         /* Buffer displayed in window   */
  67.         struct  LINE *w_linep;          /* Top line in the window       */
  68.         struct  LINE *w_dotp;           /* Line containing "."          */
  69.         short   w_doto;                 /* Byte offset for "."          */
  70.         struct  LINE *w_markp;          /* Line containing "mark"       */
  71.         short   w_marko;                /* Byte offset for "mark"       */
  72.         char    w_toprow;               /* Origin 0 top row of window   */
  73.         char    w_ntrows;               /* # of rows of text in window  */
  74.         char    w_force;                /* If NZ, forcing row.          */
  75.         char    w_flag;                 /* Flags.                       */
  76. }       WINDOW;
  77.  
  78. #define WFFORCE 0x01                    /* Window needs forced reframe  */
  79. #define WFMOVE  0x02                    /* Movement from line to line   */
  80. #define WFEDIT  0x04                    /* Editing within a line        */
  81. #define WFHARD  0x08                    /* Better to a full display     */
  82. #define WFMODE  0x10                    /* Update mode line.            */
  83.  
  84. /*
  85.  * Text is kept in buffers. A buffer header, described below, exists for every
  86.  * buffer in the system. The buffers are kept in a big list, so that commands
  87.  * that search for a buffer by name can find the buffer header. There is a
  88.  * safe store for the dot and mark in the header, but this is only valid if
  89.  * the buffer is not being displayed (that is, if "b_nwnd" is 0). The text for
  90.  * the buffer is kept in a circularly linked list of lines, with a pointer to
  91.  * the header line in "b_linep".
  92.  */
  93. typedef struct  BUFFER {
  94.         struct  BUFFER *b_bufp;         /* Link to next BUFFER          */
  95.         struct  LINE *b_dotp;           /* Link to "." LINE structure   */
  96.         short   b_doto;                 /* Offset of "." in above LINE  */
  97.         struct  LINE *b_markp;          /* The same as the above two,   */
  98.         short   b_marko;                /* but for the "mark"           */
  99.         struct  LINE *b_linep;          /* Link to the header LINE      */
  100.         char    b_nwnd;                 /* Count of windows on buffer   */
  101.         char    b_flag;                 /* Flags                        */
  102.         char    b_fname[NFILEN];        /* File name                    */
  103.         char    b_bname[NBUFN];         /* Buffer name                  */
  104. }       BUFFER;
  105.  
  106. #define BFTEMP  0x01                    /* Internal temporary buffer    */
  107. #define BFCHG   0x02                    /* Changed since last write     */
  108.  
  109. /*
  110.  * The starting position of a region, and the size of the region in
  111.  * characters, is kept in a region structure.  Used by the region commands.
  112.  */
  113. typedef struct  {
  114.         struct  LINE *r_linep;          /* Origin LINE address.         */
  115.         short   r_offset;               /* Origin LINE offset.          */
  116.         short   r_size;                 /* Length in characters.        */
  117. }       REGION;
  118.  
  119. /*
  120.  * All text is kept in circularly linked lists of "LINE" structures. These
  121.  * begin at the header line (which is the blank line beyond the end of the
  122.  * buffer). This line is pointed to by the "BUFFER". Each line contains a the
  123.  * number of bytes in the line (the "used" size), the size of the text array,
  124.  * and the text. The end of line is not stored as a byte; it's implied. Future
  125.  * additions will include update hints, and a list of marks into the line.
  126.  */
  127. typedef struct  LINE {
  128.         struct  LINE *l_fp;             /* Link to the next line        */
  129.         struct  LINE *l_bp;             /* Link to the previous line    */
  130.         short   l_size;                 /* Allocated size               */
  131.         short   l_used;                 /* Used size                    */
  132.         char    l_text[1];              /* A bunch of characters.       */
  133. }       LINE;
  134.  
  135. #define lforw(lp)       ((lp)->l_fp)
  136. #define lback(lp)       ((lp)->l_bp)
  137. #define lgetc(lp, n)    ((lp)->l_text[(n)]&0xFF)
  138. #define lputc(lp, n, c) ((lp)->l_text[(n)]=(c))
  139. #define llength(lp)     ((lp)->l_used)
  140.  
  141. /*
  142.  * The editor communicates with the display using a high level interface. A
  143.  * "TERM" structure holds useful variables, and indirect pointers to routines
  144.  * that do useful operations. The low level get and put routines are here too.
  145.  * This lets a terminal, in addition to having non standard commands, have
  146.  * funny get and put character code too. The calls might get changed to
  147.  * "termp->t_field" style in the future, to make it possible to run more than
  148.  * one terminal type.
  149.  */  
  150. typedef struct  {
  151.         short   t_nrow;                 /* Number of rows.              */
  152.         short   t_ncol;                 /* Number of columns.           */
  153. #ifndef    ST520
  154.         int     (*t_open)();            /* Open terminal at the start.  */
  155.         int     (*t_close)();           /* Close terminal at end.       */
  156.         int     (*t_getchar)();         /* Get character from keyboard. */
  157.         int     (*t_putchar)();         /* Put character to display.    */
  158.         int     (*t_flush)();           /* Flush output buffers.        */
  159.         int     (*t_move)();            /* Move the cursor, origin 0.   */
  160.         int     (*t_eeol)();            /* Erase to end of line.        */
  161.         int     (*t_eeop)();            /* Erase to end of page.        */
  162.         int     (*t_beep)();            /* Beep.                        */
  163. #endif
  164. }       TERM;
  165.  
  166. typedef struct  VIDEO {
  167.         short   v_flag;                 /* Flags */
  168.         char    v_text[1];              /* Screen data. */
  169. }       VIDEO;
  170.  
  171. typedef struct  {
  172.         short   k_code;                 /* Key code                     */
  173.         int     (*k_fp)();              /* Routine to handle it         */
  174. }       KEYBIND;
  175.  
  176. extern  int     fillcol;                /* Fill column                  */
  177. extern  int     currow;                 /* Cursor row                   */
  178. extern  int     curcol;                 /* Cursor column                */
  179. extern  int     thisflag;               /* Flags, this command          */
  180. extern  int     lastflag;               /* Flags, last command          */
  181. extern  int     curgoal;                /* Goal for C-P, C-N            */
  182. extern  int     mpresf;                 /* Stuff in message line        */
  183. extern  int     sgarbf;                 /* State of screen unknown      */
  184. extern  WINDOW  *curwp;                 /* Current window               */
  185. extern  BUFFER  *curbp;                 /* Current buffer               */
  186. extern  WINDOW  *wheadp;                /* Head of list of windows      */
  187. extern  BUFFER  *bheadp;                /* Head of list of buffers      */
  188. extern  BUFFER  *blistp;                /* Buffer for C-X C-B           */
  189. extern  short   kbdm[];                 /* Holds kayboard macro data    */
  190. extern  short   *kbdmip;                /* Input pointer for above      */
  191. extern  short   *kbdmop;                /* Output pointer for above     */
  192. extern  char    pat[];                  /* Search pattern               */
  193. extern  TERM    term;                   /*(Terminal information.        */
  194.  
  195. #ifdef ST520
  196. #define    mlputs    Cconws            /* on the ST520            */
  197. #endif
  198. extern  BUFFER  *bfind();               /* Lookup a buffer by name      */
  199. extern  WINDOW  *wpopup();              /* Pop up window creation       */
  200. extern  LINE    *lalloc();              /* Allocate a line              */
  201. extern    char    *malloc();
  202.  
  203. /* -eof- */
  204.